package com.haier.cloudremote.adapter;

import java.util.ArrayList;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.haier.cloudremote.R;
import com.haier.cloudremote.model.SwitchInfo;

public class BootStartAdapter extends BaseAdapter {

	private ArrayList<SwitchInfo> switchInfos;
	private LayoutInflater inflater;
	
	public BootStartAdapter(Context context, ArrayList<SwitchInfo> switchInfos) {
		super();
		this.switchInfos = switchInfos;
		inflater = (LayoutInflater) context.getSystemService
				(Context.LAYOUT_INFLATER_SERVICE);
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return switchInfos.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return switchInfos.get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		TextView textView; 
		SwitchInfo switchInfo = this.switchInfos.get(position);//(City)getItem(position);
		if(convertView==null){
			convertView = inflater.inflate
					(R.layout.listitem, null);
			textView = (TextView)convertView.findViewById(R.id.listitem_textView);
			convertView.setTag(textView);
		}else{
			textView = (TextView)convertView.getTag();
		}

		textView.setText(switchInfo.getSwitchName());

		return convertView;

	}

}
